package com.bookbuf.app;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.bookbuf.library.domain.User;
import com.bookbuf.module.manager.StubManager;
import com.bookbuf.module.stub.impl.BizProxyStub;

public class MainActivity extends AppCompatActivity {

    private BizProxyStub stub;

    private void setupBizModule() {

        stub = StubManager.getManager().obtain(new BizProxyStub.BizDependence() {

            @Override
            public User injectUser() {
                return User.mockUser();
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setupBizModule();
        setContentView(R.layout.activity_main);

        mockLogic();
    }

    private void mockLogic() {
        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                stub.uiInterface().callExamDetailActivity(MainActivity.this);
            }
        });
        Button bizButton = (Button) findViewById(R.id.button_biz);
        bizButton.setText(
                stub.serviceInterface().provideExaminationName()
                        + ":" +
                        stub.serviceInterface().provideExaminationAnswerCount());
    }

    @Override
    protected void onStart() {
        super.onStart();

    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
